<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Minim : : AudioInput</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body> 
<center>
<table class="mainTable">
  <tr>
    <td class="header">
    	<span class="indexheader">Minim</span><br/>
    	<span class="indexnavigation">
    		<a href="index.html">core</a> | 
    		<a href="index_ugens.html">ugens</a> | 
    		<a href="index_analysis.html">analysis</a>
    	</span>
    </td>
    <td class="border-left">&nbsp;</td>
  </tr>
  
  <tr>
    <td class="classNavigation">
    	<p class="mainTextName">AudioInput</p>
    	
       <p class="linkListHeader">Fields</p>
       <p class="linkList">
           
    <a href="audioinput_field_left.html" title="The AudioBuffer containing the left channel samples. If this is a mono
 sound, it contains the single channel of audio.">left</a><br/>
    
    <a href="audioinput_field_mix.html" title="The AudioBuffer containing the mix of the left and right channels. If this is
 a mono sound, <code>mix</code> contains the same
 samples as <code>left</code>.">mix</a><br/>
    
    <a href="audioinput_field_right.html" title="The AudioBuffer containing the right channel samples. If this is a mono
 sound, <code>right</code> contains the same samples as
 <code>left</code>.">right</a><br/>
    
	   </p>
   
    	
       <p class="linkListHeader">Methods</p>
       <p class="linkList">
           
    <a href="audioinput_method_addlistener.html" title="Add an AudioListener to this sound generating object.">addListener ( )</a><br/>
    
    <a href="audioinput_method_buffersize.html" title="The internal buffer size of this sound object.">bufferSize ( )</a><br/>
    
    <a href="audioinput_method_disablemonitoring.html" title="When monitoring is disabled, you will not hear 
 the audio that is coming through the input.">disableMonitoring ( )</a><br/>
    
    <a href="audioinput_method_enablemonitoring.html" title="When monitoring is enabled, you will be able to hear 
 the audio that is coming through the input.">enableMonitoring ( )</a><br/>
    
    <a href="audioinput_method_getbalance.html" title="Returns the current balance.">getBalance ( )</a><br/>
    
    <a href="audioinput_method_getformat.html" title="Returns AudioFormat object that describes the audio properties 
 of this sound generating object.">getFormat ( )</a><br/>
    
    <a href="audioinput_method_getgain.html" title="Returns the current gain.">getGain ( )</a><br/>
    
    <a href="audioinput_method_getpan.html" title="Returns the current pan.">getPan ( )</a><br/>
    
    <a href="audioinput_method_getvolume.html" title="Returns the current volume.">getVolume ( )</a><br/>
    
    <a href="audioinput_method_ismonitoring.html" title="Returns whether or not this AudioInput is monitoring.
 In other words, whether you will hear in your speakers
 the audio coming into the input.">isMonitoring ( )</a><br/>
    
    <a href="audioinput_method_ismuted.html" title="Returns true if the sound is muted.">isMuted ( )</a><br/>
    
    <a href="audioinput_method_mute.html" title="Mutes the sound.">mute ( )</a><br/>
    
    <a href="audioinput_method_removelistener.html" title="Removes an AudioListener that was previously 
 added to this sound object.">removeListener ( )</a><br/>
    
    <a href="audioinput_method_samplerate.html" title="Returns the sample rate of this sound object.">sampleRate ( )</a><br/>
    
    <a href="audioinput_method_setbalance.html" title="Sets the balance.">setBalance ( )</a><br/>
    
    <a href="audioinput_method_setgain.html" title="Sets the gain.">setGain ( )</a><br/>
    
    <a href="audioinput_method_setpan.html" title="Sets the pan.">setPan ( )</a><br/>
    
    <a href="audioinput_method_setvolume.html" title="Sets the volume.">setVolume ( )</a><br/>
    
    <a href="audioinput_method_shiftbalance.html" title="Transitions the balance from one value to another.">shiftBalance ( )</a><br/>
    
    <a href="audioinput_method_shiftgain.html" title="Transitions the gain from one value to another.">shiftGain ( )</a><br/>
    
    <a href="audioinput_method_shiftpan.html" title="Transitions the pan from one value to another.">shiftPan ( )</a><br/>
    
    <a href="audioinput_method_shiftvolume.html" title="Transitions the volume from one value to another.">shiftVolume ( )</a><br/>
    
    <a href="audioinput_method_type.html" title="The type is an int describing the number of channels
 this sound object has.">type ( )</a><br/>
    
    <a href="audioinput_method_unmute.html" title="Unmutes the sound.">unmute ( )</a><br/>
    
	   </p>
   
    </td>
    <td class="mainText border-left">
    	An AudioInput is a connection to the current record source of the computer. 
 How the record source for a computer is set will depend on the soundcard and OS, 
 but typically a user can open a control panel and set the source from there. 
 Unfortunately, there is no way to set the record source from Java. 
 This is particularly problematic on the Mac because the input will always wind 
 up being connected to the Mic-In, even if the user has set the input differently 
 using their audio control panel. 
 <p>
 You can obtain an AudioInput from Minim by using one of the getLineIn methods:
 <pre>
 // get the default STEREO input
 AudioInput getLineIn()
 
 // specifiy either Minim.MONO or Minim.STEREO for type
 AudioInput getLineIn(int type)
 
 // bufferSize is the size of the left, right,
 // and mix buffers of the input you get back
 AudioInput getLineIn(int type, int bufferSize)
 
 // sampleRate is a request for an input of a certain sample rate
 AudioInput getLineIn(int type, int bufferSize, float sampleRate)
 
 // bitDepth is a request for an input with a certain bit depth
 AudioInput getLineIn(int type, int bufferSize, float sampleRate, int bitDepth)
 </pre>
 In the event that an input doesn't exist with the requested parameters, 
 Minim will spit out an error and return null. In general, 
 you will want to use the first two methods listed above.
    	<p class="memberSectionHeader">Constructors</p>
    	<pre></pre>
    	
    	<p class="memberSectionHeader">Related</p>
    	<A href="minim_class_minim.html">Minim</A><BR>

    	<p class="memberSectionHeader">Example</p>
    	<pre>/**
  * This sketch demonstrates how to monitor the currently active audio input 
  * of the computer using an AudioInput. What you will actually 
  * be monitoring depends on the current settings of the machine the sketch is running on. 
  * Typically, you will be monitoring the built-in microphone, but if running on a desktop
  * it's feasible that the user may have the actual audio output of the computer 
  * as the active audio input, or something else entirely.
  * &lt;p>
  * Press 'm' to toggle monitoring on and off.
  * &lt;p>
  * When you run your sketch as an applet you will need to sign it in order to get an input.
  * &lt;p>
  * For more information about Minim and additional features, 
  * visit http://code.compartmental.net/minim/ 
  */

import ddf.minim.*;

Minim minim;
AudioInput in;

void setup()
{
  size(512, 200, P3D);

  minim = new Minim(this);
  
  // use the getLineIn method of the Minim object to get an AudioInput
  in = minim.getLineIn();
}

void draw()
{
  background(0);
  stroke(255);
  
  // draw the waveforms so we can see what we are monitoring
  for(int i = 0; i &lt; in.bufferSize() - 1; i++)
  {
    line( i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50 );
    line( i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50 );
  }
  
  String monitoringState = in.isMonitoring() ? "enabled" : "disabled";
  text( "Input monitoring is currently " + monitoringState + ".", 5, 15 );
}

void keyPressed()
{
  if ( key == 'm' || key == 'M' )
  {
    if ( in.isMonitoring() )
    {
      in.disableMonitoring();
    }
    else
    {
      in.enableMonitoring();
    }
  }
}
</pre>
    	<p class="memberSectionHeader">Usage</p>
    	Web & Application
    </td>
  </tr>
</table>
</center>
</body>
</html>